home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / Mem_PrintInUse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-16  |  2.1 KB  |  74 lines

  1. /* 
  2.  * Mem_PrintInUse.c --
  3.  *
  4.  *    Source code for the "Mem_PrintInUse" library procedure.  See memInt.h
  5.  *    for overall information about how the allocator works..
  6.  *
  7.  * Copyright 1988 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/Mem_PrintInUse.c,v 1.2 89/06/15 22:36:49 douglis Exp $ SPRITE (Berkeley)";
  19. #endif not lint
  20.  
  21. #include "memInt.h"
  22.  
  23.  
  24. /*
  25.  * ----------------------------------------------------------------------------
  26.  *
  27.  * Mem_PrintInUse --
  28.  *
  29.  *      Uses a default procedure to print out the non-binned blocks in
  30.  *    the allocator that are still in use.  The original size and the
  31.  *    PC of the call to Mem_Alloc are printed.
  32.  *
  33.  * Results:
  34.  *      None.
  35.  *
  36.  * Side effects:
  37.  *      Stuff gets printed (?) by passing it to memPrintProc.  See the
  38.  *    documentation in Mem_PrintStatsSubr for the calling sequence to
  39.  *    memPrintProc.
  40.  *
  41.  * ----------------------------------------------------------------------------
  42.  */
  43.  
  44. ENTRY void
  45. Mem_PrintInUse()
  46. {
  47.     register Address ptr;
  48.  
  49.     LOCK_MONITOR;
  50.  
  51.     if (!memInitialized) {
  52.     (*memPrintProc)(memPrintData, "Allocator not initialized yet.\n");
  53.     return;
  54.     }
  55.  
  56.     (*memPrintProc)(memPrintData, "Large objects still in use:\n");
  57.     (*memPrintProc)(memPrintData, "    Location   Orig. Size   Alloc.PC\n");
  58.  
  59.     for (ptr = memFirst; ptr != memLast; ptr += SIZE(GET_ADMIN(ptr))) {
  60.  
  61.     if (!IS_DUMMY(GET_ADMIN(ptr)) && IS_IN_USE(GET_ADMIN(ptr))) {
  62. #ifdef MEM_TRACE
  63.         (*memPrintProc)(memPrintData,"%#12x %10d %#12x\n",
  64.             ptr, GET_ORIG_SIZE(ptr), GET_PC(ptr));
  65. #else
  66.         (*memPrintProc)(memPrintData,"%#12x %10d %12s\n", ptr,
  67.             SIZE(GET_ADMIN(ptr)) - sizeof(AdminInfo), "??");
  68. #endif MEM_TRACE
  69.  
  70.     }
  71.     }
  72.     UNLOCK_MONITOR;
  73. }
  74.